<?php 
	include ('../lib/twitese.php');
	if (!isLogin()) header('location: login.php');
	
	$t = getTwitter();
	
	if ( isset($_POST['sent_id']) && isset($_POST['message']) ) {
		
		if (trim($_POST['message']) == '') {
			exit('empty');
		} else {
			$result = $t->sendDirectMessage(trim($_POST['sent_id']), tweet_decode($_POST['message']));

			if (!$result) {
				exit('fail');
			} if ($result == 'nofollow') {
				exit('nofo');
			} else {
			
				$name = $result->sender_screen_name;
				$namee = user_id_encode($name);
				$imgurl = $result->sender->profile_image_url;
				$date = formatDate($result->created_at);
				$text = formatText($result->text);
				
				$output = '';
				$output .= "
					<li style=\"border-left:3px solid #f00;\">
						<span class=\"status_author\">
							<a href=\"user.php?id=$namee\" target=\"_blank\"><img src=\"$imgurl\" title=\"$name\" /></a>
						</span>
						<span class=\"status_body\">
							<span class=\"status_id\">$result->id </span>
							<span class=\"status_word\">".tweet_encode("<a class=\"user_name\" href=\"user.php?id=$namee\">$name </a> $text")."</span>
							<span class=\"status_info\">
				<a class=\"delete_btn\" href=\"a_del.php?id=$result->id&t=m\">删除</a>
				<span class=\"date\">$date</span>
						    </span>
						</span>
					</li>
				";
				exit($output);
			}
		}
	}
?>
